package yunhe.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import yunhe.biz.ReceiptBiz;
import yunhe.entity.Customer;

@WebServlet(name="cusDetailsServlet",urlPatterns="/cusDetailsServlet")
public class cusDetailsServlet extends HttpServlet {

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	
		String cusId = request.getParameter("CID");
		ReceiptBiz receiptbiz = new ReceiptBiz();
		Customer customer=receiptbiz.checkCusById(cusId);
		HttpSession session = request.getSession();
		if(customer!=null){
			session.setAttribute("customer", customer);
			request.getRequestDispatcher("receipt/cusDetails.jsp").forward(request, response);
		}
		else{
			response.sendRedirect("checkSale.jsp");
		}
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
